package com.stone.framework.cases.controller;

import javax.validation.Valid;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.stone.framework.cases.service.CaseService;
import com.stone.framework.message.PageReqMessage;
import com.stone.framework.message.PageResMessage;
import com.stone.framework.message.cases.AllCaseReqBody;
import com.stone.framework.message.cases.AllCaseResBody;
import com.stone.framework.message.cases.CurrCaseReqBody;
import com.stone.framework.message.cases.CurrCaseResBody;

@RestController
@RequestMapping("/case")
public class CaseController {

    @Autowired
    private CaseService caseService;

    @RequestMapping("/getCurrCases")
    public PageResMessage<CurrCaseResBody>
        getCurrCases(@Valid @RequestBody PageReqMessage<CurrCaseReqBody> reqMessage) {
        IPage<CurrCaseResBody> page = caseService.queryCurrCases(reqMessage.getBody(), reqMessage.buildPageable());
        return PageResMessage.success(page);
    }

    @RequestMapping("/getAllCases")
    public PageResMessage<AllCaseResBody> getAllCases(@Valid @RequestBody PageReqMessage<AllCaseReqBody> reqMessage) {
        IPage<AllCaseResBody> page = caseService.queryAllCases(reqMessage.getBody(), reqMessage.buildPageable());
        return PageResMessage.success(page);
    }

}
